﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using MyWeb.Data;
using MyWeb.Business;
using MyWeb.Common;

namespace MyWeb.Admins
{
    public partial class Config : System.Web.UI.Page
    {
       
        Data.Config obj = new Data.Config();
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Session["Admin"].Equals("1"))
            {
                obj = ConfigService.Config_GetByAll()[0];
                txtDatetoDate.Text = "";
                txtMaxPoint.Text = obj.MaxPoint;
                txtPointLD.Text = obj.PointLD;
                txtPointNV.Text = obj.PointNV;
                txtPoitType.Text = obj.PoitType;
                txtStatus.Text = obj.Status;
                txtTotal.Text = obj.Total;
            }
            else pnUpdate.Visible = false;
        }

        protected void Update_Click(object sender, EventArgs e)
        {
            if (Page.IsValid)
            {
                obj.MaxPoint = txtMaxPoint.Text;
                obj.Status = txtStatus.Text;
                obj.PointNV = NumberClass.ConvertNumber(txtPointNV.Text, "en-US");
                obj.PointLD = NumberClass.ConvertNumber(txtPointLD.Text, "en-US");
                obj.Total = NumberClass.ConvertNumber(txtTotal.Text, "en-US");
                obj.PoitType = NumberClass.ConvertNumber(txtPoitType.Text, "en-US");
                obj.DatetoDate = txtDatetoDate.Text;
                ConfigService.Config_Update(obj);
              
                
            }
        }

    }
}